﻿using HandmadeShop.BusinessLogic.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HandmadeShop.Application
{
    public class Context
    {
        private static volatile Context instance;
        private static object synRoot = new object();

        private Context() { }

        public static Context Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (synRoot)
                    {
                        if (instance == null)
                            instance = new Context();
                    }
                }

                return instance;
            }
        }

        /// <summary>
        /// Name of session of user.
        /// </summary>
        public static string SessionName = "User";

        public User CurrentContext
        {
            get
            {
                var user = (User)System.Web.HttpContext.Current.Session[SessionName];
                return user;
            }
        }
    }
}